/////////////////////////////////////////////////////////
//	File Name	:	"CGame.h"
//
//	Author Name	:	David Brown (DB) and Steven Seufert (SMS)
//
//	Purpose		:	To contain all game related code.
/////////////////////////////////////////////////////////
//#pragma once	//	MSVStudio specific (been told it works on GCC)

////	Cross compiler (works on Borland, CodeWarrior, etc)
#ifndef _CGAME_H_
#define _CGAME_H_
//
////	Define class here
//


//	SGD Wrappers
#include "SGD Wrappers\CSGD_Direct3D.h"
#include "SGD Wrappers\CSGD_TextureManager.h"
#include "SGD Wrappers\CSGD_FModManager.h"
#include "SGD Wrappers\CSGD_DirectInput.h"
#include "CSGD_ObjectFactory.h"
#include "ObjectManager.h"
#include "CBitmapFont.h"
#include "CBase.h"
#include <string>
#include <vector>
#include <ctime>
using std::string;
#include "IGameState.h"


class CGame
{
private:
	//	Singleton pointers:
	CSGD_Direct3D*			m_pD3D;
	CSGD_TextureManager*	m_pTM;
	CSGD_FModManager*		m_pFM;
	CSGD_DirectInput*		m_pDI;
	IGameState*				m_pCurState;
	CObjectManager*			m_pOM;
	CSGD_ObjectFactory<string, CBase>*	m_pOF;
	CBitmapFont*			m_pBF;

	HWND					hwnd;

	//	Asset ids:
	int	m_nImageID;
	int	m_nSoundID;

	// Volume 
	float m_nFXVolume;
	float m_nMusicVolume;
	float m_nMusicPan;

	//	Game Timing:
	DWORD					m_dwTimeStamp;
	float					m_fElapsedTime;		//	time (in secs) between frames (dt)
	float					m_fGameTime;		//	how long the game has been running
	//	in seconds.
	DWORD					m_dwPreviousTimeStamp;	// time stamp from previous frame.
	
	int			m_nScreenH;
	int			m_nScreenW;
	int			m_nPlayW;
	int			m_nPlayH;
	bool		m_bWindowed;
	int			m_nStartingLives;			// the number of lives each player starts with in the game
	int			m_nMaxStartingLives;		// Players can't start with more lives than this
	bool		m_bTwoPlayerGame;			// true = co-op, false = single player
	//bool bIsPaused;

	//	Proper singleton:
	//	Constructor
	CGame(void);
	//	Trilogy of EVIL:
	//	Copy constructor
	CGame(const CGame&);
	//	Assignment operator
	CGame& operator=(const CGame&);
	//	Destructor
	~CGame(void);

	bool Input(void);
	void Update(void);
	void Render(void);

public:
	
	int GetScreenW(void)				{return m_nScreenW; }
	int GetScreenH(void)				{return m_nScreenH; }
	int GetPlayW(void)					{return m_nPlayW; }
	int GetPlayH(void)					{return m_nPlayH; }

	float GetMusicVolume() const		{ return m_nMusicVolume; }
	void SetMusicVolume(float val)		{ m_nMusicVolume = val; }

	float GetSFXVolume() const			{ return m_nFXVolume; }
	void SetSFXVolume(float val)		{ m_nFXVolume = val; }

	float GetPanVolume() const			{ return m_nMusicPan; }
	void SetPanVolume(float val)		{ m_nMusicPan = val; }

	void SetGameTime(float fTime)		{ m_fGameTime = fTime;}
	float GetGameTime(void)				{ return m_fGameTime;}

	HWND GetHwnd () const				{ return hwnd; }

	int GetStartingLives() const		{ return m_nStartingLives; }
	void SetStartingLives(int lives)	{ m_nStartingLives = lives; }

	int GetMaxStartingLives() const		{ return m_nMaxStartingLives; }
	void SetMaxStartingLives(int lives) { m_nMaxStartingLives = lives; }

	bool GetIsWindowed() const			{ return m_bWindowed; }
	void SetIsWindowed(bool windowed)	{ m_bWindowed = windowed; }

	//	Singleton accessor
	static CGame* GetInstance(void);

	//	3 things a game does during it's lifetime:
	//	Initialization
	void Initialize(HWND hWnd, HINSTANCE hInstance,
						int nScreenWidth, int nScreenHeight, int nPlayWidth, int nPlayHeight, bool bIsWindowed);
	//	Execution
	//	NOTE: Returns false when game should quit
	bool Main(void);
	//	Clean Up
	void Shutdown(void);
	void ChangeState( IGameState* pNewState );
	float GetElapsedTime(void){return m_fElapsedTime;}
	// alternate between full screen and windowed mode
	void ChangeWindowMode();
	// set the game to windowed mode (true) or full screen (false)
	void SetWindowMode(bool windowed);
	
};
#endif